package com.openlogic.system.service.impl;

import org.noear.solon.annotation.Component;
import org.noear.solon.annotation.Inject;

import com.mybatisflex.solon.service.impl.ServiceImpl;
import com.openlogic.common.core.constants.CacheConstant;
import com.openlogic.common.redis.service.RedisService;
import com.openlogic.system.api.domain.SysLoginLog;
import com.openlogic.system.mapper.SysLoginLogMapper;
import com.openlogic.system.service.ISysLoginLogService;

/**
 * 登录日志 服务层实现
 * @author xm
 */
@Component
public class SysLoginLogServiceImpl extends ServiceImpl<SysLoginLogMapper, SysLoginLog> implements ISysLoginLogService {

    @Inject
    SysLoginLogMapper sysLoginLogMapper;

    @Inject
    RedisService redisService;

    /**
     * 解锁用户登录状态
     * @param userName
     * @return
     */
    @Override
    public void unlock(String userName) {
        redisService.deleteCacheObject(CacheConstant.LOGIN_ERROR_KEY + userName);
    }

    /**
     * 清空登录日志
     */
    @Override
    public void clean() {
        sysLoginLogMapper.clean();
    }

}
